package com.sky.blog.util;

import com.github.dozermapper.core.Mapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author sky  2022/3/23
 * @version 1.0
 */
@Component
@Slf4j
public class DozerUtils {

    private static Mapper mapper;

    @Autowired
    public DozerUtils(Mapper mapper) {
        DozerUtils.mapper = mapper;
    }

    public static <T> T copy(Object src, Class<T> targetClass) {
        return mapper.map(src, targetClass);
    }
}
